package com.jimiopen.hadoop.simhash;

import java.io.IOException;
import java.util.ArrayList;
import java.util.HashSet;

import org.apache.hadoop.mapreduce.Reducer;

public class SimHashReducer
		extends
		Reducer<SimHashData, ArrayList<SimHashData>, SimHashData, HashSet<SimHashData>> {
	public void reduce(SimHashData key,
			Iterable<ArrayList<SimHashData>> values, Context context)
			throws IOException, InterruptedException {
		HashSet<SimHashData> dup = new HashSet<SimHashData>();
		for (ArrayList<SimHashData> val : values) {
			dup.addAll(val);
		}
		context.write(key, dup);
	}
}
